Topics |
|
The ASCII to PostScript utility is a console-based program used to convert text documents to PostScript documents suitable to send to a PostScript printer. This utility is used as test program for the PostScript Driver Class. To use this utility enter the name of the program followed by the name of the text file to convert. NOTE: If you do not specify an output file name to write to, the program will write to stdout.
as2ps myfile.txt (Write to console) as2ps myfile.txt myfile.ps (Write to myfile.ps file) as2ps myfile.txt | lp -d hplj (Pipe to a PostScript printer under UNIX) as2ps myfile.txt > LPT1 (Redirect to a PostScript printer under DOS) as2ps myfile.txt > myfile.ps (Redirect to file under UNIX and DOS)
You can pass one of several document format switches to the program from the command line. From the command line you can use a wildcard to specify a group of files, for example: *.txt would convert all files in the current directory that have a .txt extension. For a list of format switches execute the program with no arguments or with a "-?" argument: "as2ps" or "as2ps -?"
ASCII to PostScript Converter version 1031.101 Usage: as2ps [switches] infile.txt outfile.ps (optional) Switches: -? = Display this help message. -c# = Number of copies to print. Example: -c2 -d = Enable duplex printing if available. -D = Print from manual feed position. -fcode = Select a font type. Example: -fC -F = Write output to a file: infile.txt = infile.ps -h = Use page headers and numbers. -H = Use page headers and numbers with lines. -l = Print in landscape mode instead of portrait. -m# = Set left and right margins. Example: -m1.0 -M# = Set top and bottom margins. Example: -M1.0 -pcode = Select a paper size. Example: -pLET -s# = Specify font size. Example: -s10.0 -t# = Spaces between tab stops. Example: -t8 -T = Do not truncate lines that exceed margin. -u = Format UNIX man pages produced by nroff. -v = Turn verbose mode on. -W = Turn line wrap on. -y# = Use a specified paper tray. Example: -y1 Press enter to continue... Valid font codes for -f option: C - Courier, CB - Courier-Bold, CO - Courier-Oblique, CBO - Courier-BoldObligue, T - Times-Roman, TB - Times-Bold TI - Times-Italic, TBI - Times-BoldItalic, H - Helvetica HBO - Helvetica-BoldOblique, HO - Helvetica-Oblique, HB - Helvetica-Bold, S - Symbol Valid paper codes for -p option: LET - Letter size 8.5 x 11 inches LEG - Legal size 8.5 x 14 inches TAB - Tabloid size 11 x 17 inches A3 - A3 size 297mm x 420mm (11.70 x 16.55 inches) A4 - A4 size 210mm x 297mm (8.27 x 11.70 inches)
The "-c" switch is used to select the number of copies to print: "as2ps -c2 myfile.txt" will print two full copies of the document. The default is one copy per document.
The "-d" switch is used to enable duplex printing if a duplex device is attached to the printer. Each pair of consecutive pages will be printed on opposite sides of a single sheet of paper.
The "-D" switch is used to feed the paper from the printer's manual feed position.
The "-f" switch is used to select a specified font code. "asps -fT myfile" will print the document using the Times-Roman font. The default font is Courier. Other font codes include:
C - Courier, CB - Courier-Bold, CO - Courier-Oblique, CBO - Courier-BoldObligue
T - Times-Roman, TB - Times-Bold TI - Times-Italic, TBI - Times-BoldItalic
H - Helvetica, HBO - Helvetica-BoldOblique, HO - Helvetica-Oblique, HB - Helvetica-Bold
S - Symbol
The "-F" switch is used to write the output to a file instead of the stdout. The resulting PostScript file will use the same name as the text file with a ".ps" file extension. NOTE: Existing PostScript files in the program's working directory with the same name will be overwritten without prompting.
The "-h" switch is used to print a page header and a page number on each page. A page header is made up of the text file name and the current system time and date. NOTE: When selected, this option will use one-inch left/right margins and one-inch top/bottom margins.
The "-H" switch is used to print a page header and a page number on each page; both separated from the text by a line. A page header is made up of the text file name and the current system time and date. NOTE: When selected, this option will use one-inch left/right margins and one-inch top/bottom margins.
The "-l" switch is used to select landscape mode instead of portrait. The default is portrait mode.
The "-m" switch is used to set the left and right margins: "as2ps -m1.0 myfile.txt" will print the document with one-inch left and right margins. The default is none. NOTE: If the right margin is exceeded the line will be truncated unless a "-T" switch is given.
The "-M" switch is used to set the top and bottom margins: "as2ps -M1.0 myfile.txt" will print the document with one-inch top and bottom margins. The default is none.
The "-p" switch is used to select a specified paper size: "as2ps -pTAB myfile.txt" will format the document for Tabloid size paper. The default paper size if Letter size. Other paper codes include:
LET - Letter size 8.5 x 11 inches
LEG - Legal size 8.5 x 14 inches
TAB - Tabloid size 11 x 17 inches
A3 - A3 size 297mm x 420mm (11.70 x 16.55 inches)
A4 - A4 size 210mm x 297mm (8.27 x 11.70 inches)
The "-s" switch is used to specify a font size: "as2ps -s12 myfile.txt" will format the document using a 12-pitch font. The default font size is 10 pitch.
The "-t" switch is used to set the number of spaces between tabs. The default tab size is eight.
The "-T" switch is used to ensure that lines exceeding the right margin will not be truncated.
The "-u" switch is used to format UNIX man pages produced by nroff.
The "-v" switch is used to turn verbose mode on. In verbose mode the program will echo the document parameters to the screen before printing. This option is used for troubleshooting print jobs.
The "-W" switch is used to line wrap on. This will force any lines that exceed the right margin to wrap around the page.
The "-y" switch is used to specify a paper tray: "as2ps -y1 myfile.txt" will print the file to tray number one on the printer. The correspondence between tray numbers and the actual paper tray positions is specific to each printer.
Console Base Utility Program:
Four makefiles are provided in the "utils" directory to compile the source code on one of four different compilers.
"msvc40.mak" - Makefile for Microsoft visual C/C++ 4.2 "djgpp.mak" - Makefile for DJGPP gcc 2.7.2.1 "gnu_gcc.mak" - Makefile for GNU g++ 2.7.2.1 "hpux10.mak" - Makefile for HPUX C++ A.10.24
Building the Executable:
To compile use the "make -f" option followed by the makefile name. To compile using MSVC use the "nmake -f" option. The resulting executable will be named after the name set by the PROJECT macro in the makefile. By default the program will be named "as2ps" under UNIX or "as2ps.exe" under Windows 95/DOS.
Installing:
Execute a "make -f (makefile name) install" to move the executable to the "bin" directory.
Removing the Object Files and the Executable:
To remove the object files and the executable use the "make -f" option followed by the makefile name, followed by "clean": make -f hpux10.mak clean
Under MSVC use the "nmake -f" option followed by the makefile name, followed by "clean": nmake -f msvc40.mak clean